<link rel="stylesheet" type="text/css" href="<?php echo base_url() . 'public/css/dateinput.css'; ?>"/>

<?php
$sidebar =
    '<ul id=\"admin-nav\">
    <li><a href=\"' . site_url("admin/home") . '\">Admin kodu</a></li>
    <li><a href=\"' . site_url("admin/competitions") . '\">Võistlused</a></li>
    <li><a href=\"' . site_url("admin/competitions/manual") . '\">Käsitsi sisestamine</a></li>
    <li><a href=\"' . site_url("admin/tables") . '\">Aegade ja punktide tabelid</a></li>
</ul>';

$sidebar = str_replace("\n", '\n', $sidebar);
?> 
<script>
    
    $(".page-header").html("<h1>Võistluste lisamine</h1>");
    $(".sidebar").html("<?php echo $sidebar; ?>");
    
    $(document).ready(function () {
        
        $("select").addClass("form-control");
        
        $.tools.dateinput.localize("et", {
            months: 'Jaanuar,Veebruar,Märts,Aprill,Mai,Juuni,Juuli,August,September,Oktoober,November,Detsember',
            shortMonths:  'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec',
            days:         'Pühapäev,Esmaspäev,Teisipäev,Kolmapäev,Neljapäev,Reede,Laupäev',
            shortDays:    'P,E,T,K,N,R,L'
        });
  
        $(":date").dateinput({
            trigger: true,
            lang: 'et',
            firstDay: 1,
            value: 1-1,
            // this is displayed to the user
            format: 'dd.mm.yyyy'
        });
        
        $(":date:first").data("dateinput").setValue();
        $(":date:last").data("dateinput").setValue();
        
        $(":date").bind("onShow onHide", function()  {
            $(this).parent().toggleClass("active");
        });

        // a different format is sent to the server
        $(":date:first").data("dateinput").change(function() {
            var isoDate = this.getValue('yyyy-mm-dd');
            $('input[name="start_date"]').val(isoDate);
        });
        // a different format is sent to the server
        $(":date:last").data("dateinput").change(function() {
            var isoDate = this.getValue('yyyy-mm-dd');
            $('input[name="end_date"]').val(isoDate);
        });
        
    }); 
    
</script>
<div id="competition_summary">
    <h2 id="count_events_results"></h2>
    <?php echo form_open('admin/competitions/manual/add', 'class="form-horizontal" method="post"'); ?>
    <div class="form-group">
        <label for="name" class="col-sm-2 control-label">Võistluse nimi</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" id="name" name="name">
        </div>
    </div>
    <div class="form-group">
        <label for="country" class="col-sm-2 control-label">Riik</label>
        <div class="col-sm-5">
            <?php echo $country_input; ?>
        </div>
    </div>
    <div class="form-group">
        <label for="city" class="col-sm-2 control-label">Linn</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" id="city" name="city">
        </div>
    </div>
    <div class="form-group">
        <label for="facility" class="col-sm-2 control-label">Ujula</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" id="facility" name="facility">
        </div>
    </div>
    <div class="form-group">
        <label for="pool" class="col-sm-2 control-label">Bassein</label>
        <div class="col-sm-2">
            <?php echo form_dropdown('pool', array(25 => '25m', 50 => '50m'), array(), 'id="pool" name="pool" class="form-control"'); ?>
        </div>
    </div>
    <?php
    $data_start = array(
        'name' => 'data_start',
        'type' => 'date'
    );

    $data_end = array(
        'name' => 'data_end',
        'type' => 'date'
    );
    ?>
    <div class="form-group">
        <label for="start_date_visible" class="col-sm-2 control-label">Alguskuupäev</label>
        <div class="col-sm-6">
            <?php echo form_input($data_start, '', 'class="form-control" id="start_date_visible"') ?>
        </div>
    </div>
    <div class="form-group">
        <label for="end_date_visible" class="col-sm-2 control-label">Lõppkuupäev</label>
        <div class="col-sm-6">
            <?php echo form_input($data_end, '', 'class="form-control" id="end_date_visible"') ?>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button id="upload_data_btn" type="submit" class="btn btn-default">Lisa andmebaasi</button>
        </div>
    </div>

    <?php
    $data_start_hidden = array(
        'type' => 'hidden',
        'id' => 'start_date',
        'name' => 'start_date'
    );
    echo form_input($data_start_hidden);
    $data_end_hidden = array(
        'type' => 'hidden',
        'id' => 'end_date',
        'name' => 'end_date'
    );
    echo form_input($data_end_hidden);
    echo form_close();
    ?>

</div>


<?php
?>


